// ====== 方法1：把所有请求的地址封装成一个方法，好处就是有个归总 ======
//引入request.js文件
import request from "./request";
let baseUrl
if (process.env.NODE_ENV === "development") {
    baseUrl = "http://localhost:3000";
}else {
    baseUrl = 'http://43.138.208.186:9528'
}



export function getTopList(listId) {
    return request({
        url: baseUrl+`/top/list?idx=${listId}`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export function getBanner() {
    return request({
        url: baseUrl+`/banner`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export function getTop() {
    return request({
        url:baseUrl+ `/toplist`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export function getHotSongList() {
    return request({
        url: baseUrl+`/personalized?limit=8`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export function getHotSongTaps() {
    return request({
        url: baseUrl+`/playlist/highquality/tags`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export const reqAlbumNewSet = () => request({url:baseUrl+ "/album/newest", method: 'GET'});

export function reqHotSinger() {
    return request({
        url: baseUrl+`/artist/list`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export const reqDjTopList = (limit = 30) => request({
    url: baseUrl+`/dj/toplist/popular?limit=${5}`,
    method: 'GET'
});

export function reqSongListDetail(id) {
    return request({
        url:baseUrl+ `/playlist/detail?id=${id}`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写
    });
}

export function reqPlayList(limit, offset = 0, cat = '全部', order) {
    return request({//4000
        url: baseUrl+`/top/playlist?limit=${limit}&offset=${offset}&cat=${cat}&order=${order}`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写

    });
}

export const reqCatList = () => request({url:baseUrl+ '/playlist/catlist', methods: 'GET'});
export const reqSong = (ids) => request({url: baseUrl+`/song/detail?ids=${ids}`, method: 'GET'});

export function reqCommentList(id) {
    return request({
        url: baseUrl+`/comment/playlist?id=${id}`, // 这个地址是去掉公共地址剩下的地址
        method: "GET", // 请求方式 支持多种方式  get post put delete 等等
        //发送请求要配置的参数 无参数的情况下也可以不写

    });
}

export const reqCommentPlayList = (id, limit = 20, offset = 0) => request({
    url: baseUrl+`/comment/playlist?id=${id}&limit=${limit}&offset=${offset}`,
    method: 'GET'
});
export const reqCommentHot = (id, type = 0, limit = 20, offset = 0) => request({
    url: baseUrl+`/comment/hot?id=${id}&type=${type}&limit=${limit}&offset=${offset}`,
    method: 'GET'
});

//新版评论接口
export const reqNewCommentHot = (id,type=2) =>
    request({url: baseUrl+`/comment/new?type=${type}&id=${id}&sortType=2`, method: 'GET'});
export const reqAlbum = (id) =>
    request({url: baseUrl+`/album?id=${id}`, method: 'GET'});
//专辑评论
export const reqAlbumCommentHot = (id, limit = 20, offset = 0) =>
    request({url: baseUrl+`/comment/album?id=${id}&limit=${limit}&offset=${offset}`, method: 'GET'});

//修改
export const reqSongDetail = (id) => request({url: baseUrl+`/song/detail?ids=${id}`, method: 'GET'});//4000

export const reqLyric = (id) => request({url: baseUrl+`/lyric?id=${id}`, method: 'GET'});


export const reqSongCommentHot = (id, limit = 20, offset = 0) =>
    request({url: baseUrl+`/comment/music?id=${id}&limit=${limit}&offset=${offset}`, method: 'GET'});

export const reqSingerAlbum = (id, limit = 12, offset = 0) =>
    request({url: baseUrl+`/artist/album?id=${id}&limit=${limit}&offset=${offset}`, method: 'GET'});
export const reqSingerTopSongs = (id) =>
    request({url: baseUrl+`/artist/top/song?id=${id}`, method: 'GET'});
export const reqSingerDetail = (id) =>
    request({url: baseUrl+`/artist/detail?id=${id}`, method: 'GET'});
export const reqTopSinger = () =>
    request({url: baseUrl+`/top/artists?offset=0&limit=6`, method: 'GET'});
export const reqUserDetail = (id) =>
    request({url: baseUrl+`/user/detail?uid=${id}`, method: 'GET'});
export const reqCity = (code) =>
    request({url: `http://localhost:53000/city`, method: 'GET'});

export const reqUserDj = (id) =>
    request({url: baseUrl+`/user/audio?uid=${id}`, method: 'GET'});
export const reqUserSongList = (id) =>
    request({url: baseUrl+`/user/playlist?uid=${id}&limit=1000`, method: 'GET'});

// export const test = (limit=8,offset=0) =>
//     request({url: baseUrl+`/user/playlist?uid=320307906&limit=${limit}&offset=${offset}`, method: 'GET'});
//type=1 时只返回 weekData, type=0 时返回 allData
export const reqUserRecord = (id,type=0) =>
    request({url: baseUrl+`/user/record?uid=${id}&type=${type}`, method: 'GET'});

export const reqTopSingers = (limit=100,offset=0) =>
    request({url: baseUrl+`/top/artists?offset=${offset}&limit=${limit}`, method: 'GET'});

// 歌手分类列表 artist/list
// limit : 返回数量 , 默认为 30
// offset : 偏移数量，用于分页 , 如 : 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0
// initial: 按首字母索引查找参数,如 /artist/list?type=1&area=96&initial=b 返回内容将以 name 字段开头为 b 或者拼音开头为 b 为顺序排列, 热门传-1,#传 0
// type 取值:
export const reqArtistsList = (type=-1,area=-1,initial=-1,limit=100,offset=0)=>request({url:baseUrl+`/artist/list?type=${type}&area=${area}&initial=${initial}&limit=${limit}&offset=${offset}`,method:'GET'});
// baseUrl+'/simi/song?id=412785876'
export const reqSimiSong = (id) =>
    request({url: baseUrl+`/simi/song?id=${id}`, method: 'GET'});

// 获取全部新碟 /album/new?area=KR&limit=10
// limit : 返回数量 , 默认为 30
// offset : 偏移数量，用于分页 , 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0
// area : ALL:全部,ZH:华语,EA:欧美,KR:韩国,JP:日本
export const reqAlbumNew = (limit=35,offset=0,area="ALL")=>request({url:baseUrl+`/album/new?area=${area}&limit=${limit}&offset=${offset}`,method:'GET'});
// 获取歌手专辑 /artist/album
export const reqArtistAlbum = (id,limit=12,offset=0)=>request({url:baseUrl+`/artist/album?id=${id}&limit=${limit}&offset=${offset}`,method:'GET'});

export const reqArtistMv = (id)=>request({url:baseUrl+`/artist/mv?id=${id}`,method:'GET'});

export const reqArtistDescription = (id)=>request({url:baseUrl+`/artist/desc?id=${id}`,method:'GET'});

export const reqCateList = ()=>request({url:baseUrl+`/dj/catelist`,method:'GET'});

export const reqProgramList = ()=>request({url:baseUrl+`/program/recommend`,method:'GET'});

export const reqTopProgramList = (limit=10)=>request({url:baseUrl+`/dj/program/toplist?limit=${limit}`,method:'GET'});

//获取电台 - 类别热门电台 /dj/radio/hot?cateId=2001
// limit : 返回数量 , 默认为 30
// offset : 偏移数量，用于分页 , 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0
// cateId: 类别 id,可通过 /dj/category/recommend 接口获取
export const reqRadio =  (cateId,limit = 22,offset=0)=>request({url:baseUrl+`/dj/radio/hot?cateId=${cateId}&limit=${limit}&offset=${offset}`,method:'GET'});

export const reqDjProgram =  ()=>request({url:baseUrl+`/dj/program/toplist?limit=100`,method:'GET'});

export const reqDjProgramDetail =  (id)=>request({url:baseUrl+`/dj/program/detail?id=${id}`,method:'GET'});
export const reqRadioDetail =  (id)=>request({url:baseUrl+`/dj/detail?rid=${id}`,method:'GET'});
export const reqUserRadioList =  (id)=>request({url:baseUrl+`/dj/program?rid=${id}`,method:'GET'});
export const reqHotRadio =  ()=>request({url:baseUrl+`/dj/recommend`,method:'GET'});
export const reqSongUrl = (id)=>request({url:baseUrl+`/song/url?id=${id}`,method:'GET'});
export const reqSongLyric = (id)=>request({url:baseUrl+`/lyric?id=${id}`,method:'GET'});
export const reqEvent = (id)=>request({url:baseUrl+`/user/event?uid=${id}`,method:'GET'});
export const reqFans =  (id,limit = 20,offset=0)=>request({url:baseUrl+`/user/followeds?uid=${id}&limit=${limit}&offset=${offset}`,method:'GET'});
export const reqFollows =  (id,limit = 20,offset=0)=>request({url:baseUrl+`/user/follows?uid=${id}&limit=${limit}&offset=${offset}`,method:'GET'});

export const reqHotEvent = (id,pagesize=10)=>request({url:baseUrl+`/topic/detail/event/hot?actid=${id}&pagesize=${pagesize}`,method:'GET'});
export const reqHotEventDetail = (id)=>request({url:baseUrl+`/topic/detail?actid=${id}`,method:'GET'});
export const SearchKeywords = (keywords)=>request({url:baseUrl+`/search/suggest?keywords=${keywords}`,method:'GET'});
export const SearchAllKeywords = (keywords,type)=>request({url:baseUrl+`/cloudsearch?keywords=${keywords}&type=${type}`,method:'GET'});
export const reqSearchSuggest = (keywords) => request({url:baseUrl+`/search/suggest?keywords=${keywords}`,method:'GET'});
export const reqMvUrl = (id)=>request({url:baseUrl+`/mv/url?id=${id}`,method:'GET'});
export const reqVideoUrl = (id)=>request({url:baseUrl+`/video/url?id=${id}`,method:'GET'});
export const reqMvDetail = (id)=>request({url:baseUrl+`/mv/detail?mvid=${id}`,method:'GET'});
export const reqMvNum = (id)=>request({url:baseUrl+`/mv/detail/info?mvid=${id}`,method:'GET'});
export const reqVideoDetail = (id)=>request({url:baseUrl+`/video/detail?id=${id}`,method:'GET'});
export const reqMvComment = (id,limit = 20, offset = 0)=>request({url:baseUrl+`/comment/mv?id=${id}&limit=${limit}&offset=${offset}`,method:'GET'});
export const reqVideoComment = (id,limit = 20, offset = 0)=>request({url:baseUrl+`/comment/video?id=${id}&limit=${limit}&offset=${offset}`,method:'GET'});
export const reqSimiMv = (id)=>request({url:baseUrl+`/related/allvideo?id=${id}`,method:'GET'});
export const reqKey = (data) => request({
    url: baseUrl+`/login/qr/key`,
    method: 'GET',
    params:data
});
export const reqQr = (data) => request({
    url: baseUrl+`/login/qr/create`,
    method: 'GET',
    params:data
});
export const reqQrCheck = (data) => request({
    url: baseUrl+`/login/qr/check`,
    method: 'GET',
    params:data
});
// 注册
export const reqRegister = (data) => request({
    url: baseUrl+`/register/cellphone`,
    method: 'GET',
    params:data
});
export const reqLogin = (data) => request({
    url: baseUrl+`/login/cellphone`,
    method: 'GET',
    params:data
});
// 发送验证码
export const reqRegisterCode = (data) => request({
    url: baseUrl+`/captcha/sent`,
    method: 'GET',
    params:data
});
export const reqVerifyCode = (data) => request({
    url: baseUrl+`/captcha/verify`,
    method: 'GET',
    params:data
});
export const reqUserAccount = (cookie)=>request({url:baseUrl+`/login/status?cookie=${cookie}`,method:'GET'});

export const reqCountry = ()=>request({url:baseUrl+`/countries/code/list`,method:'GET'});
export const reqUserLevel = (cookie)=>request({url:baseUrl+`/user/level?cookie=${cookie}`,method:'GET'});
export const reqUserLogout = (cookie)=>request({url:baseUrl+`/logout?cookie=${cookie}`,method:'GET'});
export const reqUserMsg = (cookie)=>request({url:baseUrl+`/msg/private?cookie=${cookie}`,method:'GET'});
export const reqHistoryMsg = (id,cookie)=>request({url:baseUrl+`/msg/private/history?uid=${id}&cookie=${cookie}`,method:'GET'});

export const reqNickname = (nickname)=>request({url:baseUrl+`/nickname/check?nickname=${nickname}`,method:'GET'});
export const UserUpdate = (data) => request({
    url: baseUrl+`/user/update`,
    method: 'GET',
    params:data
});
